﻿using System;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;

namespace PoolKit.Tests
{
    [TestFixture]
    public class DynamicPoolTests
    {
        [Test]
        public void MakeSureDynamicPoolCannotBeDrained()
        {
            var startingResourcePool = new List<string>();

            using (var dynamicPool = Pools.CreateDynamicPool(
                startingResourcePool,
                new Mock<ReusePreparationStrategy<string>>().Object,
                new Mock<RepairStrategy<string>>().Object,
                new ResourceCreationFunction<string>(() => { return Guid.NewGuid().ToString("N"); },
                                                     ThreadingContract.Multithreaded),
                15,
                TimeSpan.FromHours(5)))
            {
                var resourcesTaken = new List<string>();

                for (int i = 0; i < 15000; i++)
                {
                    resourcesTaken.Add(dynamicPool.Lend());
                }
            }
        }
    }
}